<?php
class modelExample extends coreModel
{
    public function get()
    {
        $this->helper->order_by('idx', 'DESC');
        
        $sSql = $this->helper->get('ex_article');
        
        $aRow = $this->query($sSql);
        
        return $aRow;
    }
    
    public function isLogin($sId, $sPass)
    {
        $this->helper->select('count(*) as cnt');
        
        $this->helper->where(array(
            'user_id' => $sId,
            'user_passwd' => $sPass
        ));
        
        $sSql = $this->helper->get('ex_member');

        $aRow = $this->query($sSql, FW_MODEL_RESULT_ROW);
        
        $iCnt = $aRow['cnt'];
        
        return $iCnt > 0 ? true : false;
    }
    
    public function write($sSubject, $sContents)
    {
        $sSql = $this->helper->insert('ex_article', array(
            'subject' => $sSubject,
            'contents' => $sContents,
            'regdate' => date('Y-m-d H:i:s')
        ));
        
        return $this->query($sSql) !== false ? true : false;
    }
    
    public function delete($iIdx)
    {
        $sSql = $this->helper->delete('ex_article', array(
            'idx' => $iIdx
        ));
        
        return $this->query($sSql) !== false ? true : false;
    }
}